package crazymakercircle;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.embedded.EmbeddedChannel;

/**
 * @Author: DRevelation
 * @Date: 2021/7/21 10:12
 */
public class InHandlerDemoTest {
    public static void main(String[] args) {
        InHandlerDemo in = new InHandlerDemo();
        InHandlerDemo2 in2 = new InHandlerDemo2();
        ChannelInitializer<EmbeddedChannel> i = new ChannelInitializer<EmbeddedChannel>() {
            @Override
            protected void initChannel(EmbeddedChannel ch) throws Exception {
                ch.pipeline().addLast(in);
                ch.pipeline().addLast(in2);
            }
        };
        EmbeddedChannel channel = new EmbeddedChannel(i);
        ByteBuf buf = Unpooled.buffer();
        buf.writeByte(1);
        channel.writeInbound(buf);
        channel.flush();
        channel.writeInbound(buf);
        channel.flush();
        channel.close();
    }
}
